import Vue from 'vue'
import 'babel-polyfill'
import App from './App'
import store from './store'
import i18n from './lang'; // Internationalization
import router from './router'
import ElementUI from 'element-ui'
// CSS重置的现代替代方法
import 'normalize.css/normalize.css'
import 'element-ui/lib/theme-chalk/index.css'

// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor, /* { default global options } */)

import service from "./utils/request";
Vue.prototype.instance = service  //axios实例
Vue.prototype.w = '/w';
Vue.prototype.imgUrl='/imgUrl'
// 全局css
import '@/styles/index.scss'
// 配置iview
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css';

Vue.use(ViewUI);

import '@/icons' // icon
import '@/permission' // 权限控制

Vue.use(ElementUI, {
  size: 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
});


// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)
//刷新保存状态
if (sessionStorage.getItem("store")) {
  store.replaceState(
    Object.assign(
      {},
      store.state,
      JSON.parse(sessionStorage.getItem("store"))
    )
  );
  sessionStorage.removeItem("store")
}

//监听，在页面刷新时将vuex里的信息保存到sessionStorage里
window.addEventListener("beforeunload", () => {
  sessionStorage.setItem("store", JSON.stringify(store.state));
});


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router,
  i18n,
  components: { App },
  template: '<App/>'
})
